home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of Shareware
/
Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso
/
mac
/
ZIPPED
/
DOS
/
GRAPHICS
/
LISS151.ZIP
/
LISSSRC.ZIP
/
OUTPUT.H
< prev
Wrap
C/C++ Source or Header
|
1992-04-13
|
7KB
|
184 lines
/* ***********************
OUTPUT.H
All the function prototypes and a couple of structures needed
for OUTPUT.C
This program displays spherical Lissajous figures
and writes a data file in either Vivid, Persistence of Vision
(PoV), or Connect the Dots Smoother (CTDS) format.
Program originally written by Dan Farmer using algorithms from
Clifford Pickover. Converted from QuickBasic to C by Aaron C. Caba.
See Scientific American January 1991 and Omni February 1990 for
excellent examples by Pickover.
History:
Version 1.5:
04/06/92 ACC Add the prototypes for new PoV 1.0 stuff
Version 1.4:
02/11/92 ACC Major rearangement of all code:
clean up header files so only necessary stuff is in each
*************************/
#ifndef _OUTPUT
#define _OUTPUT
#include <alloc.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "defines.h" /* global enums and defines */
#include "error_fn.h" /* error handling routines */
#include "field.h" /* for field input/display functions */
/* ****************************** defines ********************************** */
#define MAX_OUTPUT_COLORS 18 /* different colors allowed in output file */
#define EPSILON 1e-7
#define POV_VER_05 0
#define POV_VER_10 1
/* ************************** external variables *************************** */
extern int parm_field;
/* ********************* the structures used in output.c ******************* */
/* to track the high/low values in the x, y, and z components */
struct max_vals {float xl; float yl; float zl;
float xh; float yh; float zh;};
/* a node in a binary tree */
struct pnode {
int n; /* which sphere it is: queue[n] */
float t; /* what percentage of the period of the figure this point is at: 0-1 */
struct pnode far *left; /* pointer to left child */
struct pnode far *right; /* " " right child */
};
/* ************************* fuction prototypes *************************** */
/* This function should figure out the period of the algorithm
based on the a,b, and exponent variables. */
double algo_period(char *data[]);
void choose_pv_output(struct queue_type queue[], int index[],
int num_sph, char *data[]);
void choose_v_output(struct queue_type queue[], int index[],
int num_sph, char *data[]);
struct pnode *ctds_sort(struct pnode *root, int num_sph, double period);
/* sort the spheres by the period of the particular 'algo' used,
and write the output file to disk */
void ctds_output(struct queue_type queue[], const int num_sph, char *data[]);
/* macro to determine equality using EPSILON */
#define equal(a,b) ((fabs((a)-(b)) <= EPSILON) ? TRUE : FALSE)
#define even(x) ( ((2*(x/2)) == x) ? TRUE : FALSE )
/* free up the memmory used by the binary tree */
void free_tree(struct pnode *p);
void ftreeprint(FILE *stream, struct queue_type queue[],
struct pnode *p, int r, struct max_vals *val);
double gcd(double a, double b);
/* Input filename and append 'ext' to it */
char *input_name(char *ext);
double lcm(double x, double y, double z);
/* main routine, routes program to whatever output the user selects */
void output(struct queue_type queue[], int index[], int number, char *data[]);
/* returns pointer to memmory chunk of size 'sizeof(pnode)' */
struct pnode *palloc(void);
/* have user input colors and write the PoV data file */
void pv_output(struct queue_type queue[], int index[],
int number, char *data[], int version);
void raw_output(struct queue_type queue[], int index[],
int num_sph, char *data[]);
void smooth_v_output(struct queue_type queue[], int index[],
int num_sph, char *data[]);
void sort_index(struct queue_type queue[], int index[],
struct pnode *p, int *count);
/* add a node to the binary tree */
struct pnode *tree(struct pnode *p, int i, double i_per);
/* write the Vivid output file */
void v_output(struct queue_type queue[], int index[],
int num_sph, char *data[]);
void write_craw_spheres(struct queue_type queue[], int num_sph, char *data[]);
void write_ctds_footer(FILE *stream, char *name,
char *data[], struct max_vals val);
void write_ctds_header(FILE *stream, char *name);
void write_ctds_spheres(FILE *stream, struct queue_type queue[],
struct pnode *p, int r, struct max_vals *val);
/* write to file 'stream' the hi/low values, and finish the file */
void write_pv05_footer(FILE *stream, char *name,
char *data[], struct max_vals val);
void write_pv10_footer(FILE *stream, char *name,
char *data[], struct max_vals val);
/* write to file 'stream' the camera location, a light source
and the user declared colors for the figure */
void write_pv05_header(FILE *stream, char *name, int actualcolors,
char *output_color[], int radius, char *axis);
void write_pv10_header(FILE *stream, char *name, int actualcolors,
char *output_color[], int radius, char *axis);
/* record high/low values of coordinates, and write the spheres
in order of 'index' */
void write_pv05_spheres(FILE *stream, struct queue_type queue[], int index[],
int actualcolors, int num_sph, struct max_vals *val);
void write_pv10_spheres(FILE *stream, struct queue_type queue[], int index[],
int actualcolors, int num_sph, struct max_vals *val);
void write_raw_spheres(struct queue_type queue[], int index[], int num_sph);
void write_smooth_v_spheres(FILE *stream, struct queue_type queue[], int index[],
int radius, int num_sph, struct max_vals *val);
void write_stats(FILE *stream, char *prefix, char *data[],
struct max_vals val, float r);
/* write to file 'stream' the hi/low values and finish the file */
void write_v_footer(FILE *stream, char *name, char *data[],
struct max_vals val);
/* write to file 'stream' the studio definition and a light source */
void write_v_header(FILE *stream, char *name, char *axis);
/* redord high/low valuse of coordinates, and write the spheres
in the order stored in 'index' */
void write_v_spheres(FILE *stream, struct queue_type queue[], int index[],
int r, int num_sph, struct max_vals *val);
#endif
/* end-of-file output.h */